home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Text / Edit / GoldED-Demo / installdata / golded / developer / scanner / examples / amigaguide / guide.c
Encoding:
C/C++ Source or Header  |  1999-12-03  |  2.0 KB  |  75 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   Scan handler looking for AmigaGuide nodes (DICE-C).
  4.  
  5.   Scan handlers are plain functions (loadSeg()'ed): no standard C startup
  6.   code and no library calls permitted. We have to put string constants into
  7.   the code segment (DICE compiler: option -ms1).
  8.  
  9.   DICE:
  10.   
  11.   dcc guide.c -// -l0 -md -ms1 -mRR -o golded:etc/scanner/guide
  12.  
  13.   ------------------------------------------------------------------------------
  14. */
  15.  
  16. #include <exec/types.h>
  17.  
  18. #define UPPER(a) ((a) & 95)
  19.  
  20. ULONG
  21. ScanHandlerGuide(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
  22. {
  23.     const char *version = "$VER: Guides 1.3 (" __COMMODORE_DATE__ ")";
  24.  
  25.     if (**text == '@') {
  26.  
  27.         if (len > 4) {
  28.  
  29.             UBYTE *next = *text + 1;
  30.  
  31.             if (UPPER(*next++) == 'N') {
  32.  
  33.                 if (UPPER(*next++) == 'O') {
  34.  
  35.                     if (UPPER(*next++) == 'D') {
  36.  
  37.                         if (UPPER(*next++) == 'E') {
  38.  
  39.                             UWORD letters = 0;
  40.  
  41.                             for (len -= 5; len; --len) {
  42.  
  43.                                 if (*next == '"') {
  44.  
  45.                                     for (*text = ++next, --len; len && (*next != '"'); ++next)
  46.                                         ++letters;
  47.  
  48.                                     return(letters);
  49.                                 }
  50.                                 else if (*next == ' ')
  51.  
  52.                                     next++;
  53.  
  54.                                 else {
  55.  
  56.                                     for (*text = next; len-- && (*next != ' ') && (*next != '"'); ++next)
  57.                                         ++letters;
  58.  
  59.                                     return(letters);
  60.                                 }
  61.                             }
  62.  
  63.                             *text = "(unnamed)";
  64.  
  65.                             return(9);
  66.                         }
  67.                     }
  68.                 }
  69.             }
  70.         }
  71.     }
  72.  
  73.     return(FALSE);
  74. }
  75.